package top.heliming.youyou.config;

import java.security.PublicKey;
import javax.annotation.PostConstruct;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import top.heliming.youyou.util.RsaUtils;

/**
 * description: //网关的登录拦截器
 *
 * @author: heliming
 * @date:2019/06/09 下午 5:37
 */
@Slf4j
@Data
@ConfigurationProperties(prefix = "leyou.jwt")
public class JwtProperties {
  // 公钥
  private String pubKeyPath;
  // 公钥
  private PublicKey publicKey;

  private String cookieName;

  @PostConstruct
  public void init(){
    try {
      // 获取公钥和私钥
      this.publicKey = RsaUtils.getPublicKey(pubKeyPath);
    } catch (Exception e) {
      log.error("初始化公钥失败！", e);
      throw new RuntimeException();
    }
  }
}
